export const downloadFile = (data, headers) => {
    let fileName;
    if (headers["content-disposition"]) {
        fileName = headers["content-disposition"].replace(
            /\w+;filename=(.*)/,
            "$1"
        );
    } else {
        fileName = data.fileName;
    }
    const blob = new Blob([data], { type: headers["content-type"] });
    const dom = document.createElement("a");
    const downUrl = window.URL.createObjectURL(blob);
    dom.href = downUrl;
    dom.download = decodeURIComponent(fileName);
    dom.style.display = "none";
    document.body.appendChild(dom);
    dom.click();
    dom.parentNode.removeChild(dom);
    window.URL.revokeObjectURL(downUrl);
};
function pad(num) {
    return num.toString().padStart(2, "0");
}
export const formatDateTime = date => {
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    return `${year}-${pad(month)}-${pad(day)}`;
};
